#include <stdio.h>
#include <string.h>

void test_empty_line(FILE *fp)
{
	char buf[1024] = {0};
	char *tmp = NULL;
	while( fgets(buf, 1024, fp) != NULL ) {
		if ( buf[0] == '\n' || buf[0] == '\0' || buf[0] == '\r' ) {
			printf("Empty line\n");
			continue;
		}
		if ((tmp = strchr(buf, '\r')) != NULL) {
			*tmp = '\0';
		} else if ((tmp = strchr(buf, '\n')) != NULL) {
			*tmp = '\0';
		}
		printf("buf:%s\n", buf);
	}
}



int main(int argc, char **argv)
{
	FILE *fp = fopen(argv[1], "r");
	size_t i;
	char str[1024]={0};
	double v = 0;
	long offset;
	char c;
	//printf("%0.30f\n", v);
	//fscanf(fp, "%lf%*1[\n]", &v);
	//printf("%0.30f\n", v);
	//test_empty_line(fp);

	//getline( NULL, &i, fp );
	fgets(str, 1024, fp);
	while( !feof(fp) ) {
		c = 0;
		c = fgetc(fp);
		printf("%d:%c \n", c, c);
		//fgets(NULL, 2048, fp);
		//printf("%ld\n", ftell(fp));
	}
	//printf("%ld\n", ftell(fp));
	//fscanf(fp, "%d\n",&i);
	//printf("%ld i[%d]\n", ftell(fp), i);
	//fgets(str, 1024, fp);
	//printf("%ld [%d:%s]\n", ftell(fp), i,str);

	printf("\\n : %x\n", '\n');
	printf("\\r : %x\n", '\r');
	return 0;
}
